@extends('layout.master')

@section('title')
Welcome - Arthur
@stop

@section('username')
{{ Auth::user()->userName }}
@stop

@section('header')
@parent
@stop

@section('content')

	<div style="float:left">
	
		<h3>{{$name1}}'s Purchase History</h3> <hr />
		
		
		@if(empty($list))
        <h3> You have no previous orders with us </h3>
    	@else
    	
    	<table class="table table-bordered">
        	<thead>
	    		<th style='padding-left: 50px'>Invoice</th>
	    		<th style='padding-left: 50px'>Product Name</th>
	    		<th style="padding-left: 50px">Qunatity</th>
	    		<th style="padding-left: 50px">Retail Price</th>
	    		<th style="padding-left: 50px">Total Price</th>
	    		<th style="padding-left: 50px">Date Purchased</th>
	    	</thead>
	    	<tbody>
		
		<?php $total = 0; 
            foreach($list as $item)
            {                

                echo "
                <tr>
                    <td style='padding-left: 50px; text-align:center'>" .$item->id. "</td>
                    <td style='padding-left: 50px'>" .$item->productName. "</td>  
                    <td style='padding-left: 50px; text-align:center'>" .$item->quantity. "</td> 
                    <td style='padding-left: 50px; text-align:center'>" .$item->retailPrice. "</td> 
                    <td style='padding-left: 50px; text-align:center'>" .$item->retailPrice*$item->quantity. "</td>  
                    <td style='padding-left: 50px; text-align:center'>" .$item->tran_date. "</td>                   
                </tr>";
				//var_dump($item);
				$total += $item->retailPrice*$item->quantity;

            }            
       ?>
       
       <tr> 
                <td style='padding-left: 50px; text-align:center'> </td> 
                <td style='padding-left: 50px; text-align:center'></td> 
                <td style='padding-left: 50px; text-align:center'> </td> 
                <td style='padding-left: 50px; text-align:center'><strong>Total Spent</strong></td> 
                <td style='padding-left: 50px; text-align:center'> <strong> R{{$total}} </strong> </td>
       </tbody>
       </table>
       @endif
		
	</div>

@stop